<!DOCTYPE html>
<html>
    <body>
        <form action="" method="post">
            用户名：<input type="text" id="username"/><br/><br/>
            密码：<input type="password" id = "pwd"/><br/><br/>
            电子邮箱<input type="text" id="email"/><br/><br/>
            手机号码<input type="text" id = "tel"/><br/><br/>
            <input type="button" name="" id="btn" value="验证"/>
        </form>
        <script type="text/javascript"> 
            window.onload=function(){
                var btn = document.getElementById("btn");
                btn.onclick=function(){
                var username = document.getElementById("username").value;
                var pwd = document.getElementById("pwd").value;
                var email = document.getElementById("email").value;
                var tel = document.getElementById("tel").value;
                var regUsername = /^[a-zA-Z][a-zA-Z0-9]{3,15}$/
                var regPwd=/^[a-zA-Z0-9]{4,10}$/;
                var regEmail = /^\w+@\w+\.[a-zA-Z]{2,3}(\.[a-zA-Z]{2,3})?$/;
                var regTel = /^1[35784]\d{9}$/;
                if(regUsername.test(username)){
                    alert("用户名验证通过");
                }else{
                    alert("用户名不正确！");
                }             
                if(regPwd.test(pwd)){
                    alert("密码验证通过");
                }else{
                    alert("密码不正确!");
                }
                if(regEmail.test(email)){
                    alert("电子邮箱验证通过");
                }else{
                    alert("电话邮箱不正确！");
                }
                if(regTel.test(tel)){
                    alert("电话号码验证通过");
                }else{
                    alert("电话号码不正确！");
                }
            }
        }
        </script>
    </body>
</html>